package com.huanxing.cloud.miniapp.dubbo;

import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.shop.request.shipping.WxMaOrderShippingInfoUploadRequest;
import com.huanxing.cloud.common.security.handler.HxBusinessException;
import com.huanxing.cloud.miniapp.api.remote.RemoteSecOrderService;
import com.huanxing.cloud.miniapp.config.WxMaConfiguration;
import lombok.RequiredArgsConstructor;
import me.chanjar.weixin.common.error.WxErrorException;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

@Service
@DubboService
@RequiredArgsConstructor
public class RemoteSecOrderServiceImpl implements RemoteSecOrderService {

	@Override
	public void uploadShippingInfo(WxMaOrderShippingInfoUploadRequest wxMaOrderShippingInfoUploadRequest,
			String appId) {
		final WxMaService wxService = WxMaConfiguration.getMaService(appId);

		try {
			wxService.getWxMaOrderShippingService().upload(wxMaOrderShippingInfoUploadRequest);
		}
		catch (WxErrorException e) {
			throw new HxBusinessException(e.getMessage());
		}
	}

}
